home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbasicpg.zip / SALES.BAS < prev    next >
BASIC Source File  |  1989-08-31  |  2KB  |  83 lines

  1. ' SALES.BAS
  2. ' This program tracks the sales of soda over a given number of months.
  3.  
  4. CLS
  5.  
  6. PRINT "** Soda sales tracking program **"
  7. PRINT
  8. DO
  9.     INPUT "How many brands of soda do you sell?  ", brands%
  10. LOOP WHILE (brands% < 1)
  11. DO
  12.     INPUT "How many months would you like to record (1-12)?  ", months%
  13. LOOP WHILE (months% < 1) OR (months% > 12)
  14. PRINT
  15.  
  16. OPTION BASE 1                     ' set first array element at 1
  17. DIM sodaSales%(brands%, months%)  ' dimension soda sales array
  18. DIM brandNames$(brands%)          ' dimension brand name array
  19.  
  20. ' get names of soda brands sold
  21.  
  22. PRINT "Enter the"; brands%; "brands of soda you sell"
  23. PRINT
  24. FOR i% = 1 TO brands%
  25.     INPUT "Brand name:  ", brandNames$(i%)
  26. NEXT i%
  27.  
  28. ' get soda sales for each month
  29.  
  30. PRINT
  31. PRINT "Enter soda sales in cases"
  32. PRINT
  33.  
  34. FOR i% = 1 TO brands%         ' for each brand of soda...
  35.     PRINT "** "; brandNames$(i%); " **"
  36.     PRINT                     '   print name of brand
  37.     FOR j% = 1 TO months%     ' for each month...
  38.         READ mo$              '   read month name from DATA list
  39.         PRINT "  "; mo$;      '   print month name and prompt for input
  40.         INPUT ":  ", sodaSales%(i%, j%)  ' store input in array
  41.     NEXT j%
  42.     PRINT
  43.     RESTORE                   ' rewind DATA list to first month
  44. NEXT i%
  45.  
  46. ' print out soda sales table
  47.  
  48. CLS
  49.  
  50. PRINT "Soda sales in cases for"; months%; "months"
  51. PRINT
  52. PRINT "--------------------------------------------------------------"
  53. PRINT "Brand/Month   ";
  54.  
  55. FOR i% = 1 TO months%
  56.     PRINT " ";
  57.     READ mo$                  ' read month name from DATA list
  58.     PRINT mo$;                ' print month names across top of table
  59. NEXT i%
  60.  
  61. PRINT
  62. PRINT "--------------------------------------------------------------"
  63.  
  64. ' templates for PRINT USING
  65.  
  66. nameTmp$ = "\            \"   ' for brand name (up to 12 digits)
  67. salesTmp$ = " ###"            ' for cases sold (up to 3 digits)
  68.  
  69. FOR i% = 1 TO brands%         ' fills in the table
  70.     PRINT USING nameTmp$; brandNames$(i%);
  71.     FOR j% = 1 TO months%
  72.         PRINT USING salesTmp$; sodaSales%(i%, j%);
  73.     NEXT j%
  74.     PRINT
  75. NEXT i%
  76.  
  77. PRINT "--------------------------------------------------------------"
  78.  
  79. ' data for READ statements above
  80.  
  81. DATA Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
  82.  
  83.